<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title th:text="${question.title}"></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

    <link rel="stylesheet" href="/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="/css/bootstrap-theme.min.css"/>
    <link rel="stylesheet" href="/css/community.css"/>
    <link rel="stylesheet" href="/css/editormd.preview.css"/>
    <script src="/js/jquery-3.4.1.min.js" type="application/javascript"></script>
    <script src="/js/community.js" type="application/javascript"></script>
    <script src="/js/bootstrap.min.js" type="application/javascript"></script>
    <script src="/js/moment.js" type="application/javascript"></script>
    <script src="/js/editormd.min.js" type="application/javascript"></script>
    <script src="/editorlib/marked.min.js"></script>
    <script src="/editorlib/prettify.min.js"></script>

</head>
<body>
<div th:insert="~{navigation::nav}"></div>

<div class="container-fluid main">
    <!--左边正文-->
    <div class="row container-left col-lg-9 col-md-12 col-sm-12 col-xs-12 question-right">

        <!--标题-->
        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
            <h4 class="question_title"><span th:text="${question.title}"></span></h4>
            <span class="text-desc">
                作者:<span th:text="${question.user.name}"></span> |
                发布时间: <span th:text="${#dates.format(question.gmtCreate,'yyyy-MM-dd HH:mm')}"></span>|
                阅读数:<span th:text="${question.viewCount}"></span>

               </span><br/>
            <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12"/>
            <!--内容-->
            <!--<div th:text="${question.description}">-->


            <!--</div>-->
            <div id="markdown-view">
                <!-- Server-side output Markdown text -->
                <textarea style="display:none;" th:text="${question.description}">### Hello world!</textarea>
            </div>
            <script type="text/javascript">
                $(function () {
                    var testView = editormd.markdownToHTML("markdown-view", {
//                         markdown : "[TOC]\n### Hello world!\n## Heading 2", // Also, you can dynamic set Markdown text
//                         htmlDecode : true,  // Enable / disable HTML tag encode.
//                         htmlDecode : "style,script,iframe",  // Note: If enabled, you should filter some dangerous HTML tags for website security.
                    });
                });
            </script>
            <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12"/>

            <!--<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">-->
            <span class="question-tag label label-info" th:each="tag:${question.tag.split(',')}">
                    <span class="glyphicon glyphicon-tags"></span>
                    <span class="label label-info" th:text="${tag}"></span>
                </span>

            <!--编辑-->
            <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12"/>
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <a th:href="@{'/publish/'+${question.id}}"
                   th:if="${session.user!=null && session.user.id==question.creator}" class="community-menu">
                    <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
                    编辑
                </a>
            </div>
            <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12"/>
        </div>

        <!--评论-->
        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
            <h4>
                <span th:text="${question.commentCount}"></span>个回复
            </h4>
            <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12 comment-sp"/>
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 " th:each="comment:${comments}">
                <div class="media  comments">
                    <div class="media-left">
                        <a href="#">
                            <img class="media-object img-rounded" th:src="${comment.user.avatarUrl}">
                        </a>
                    </div>
                    <div class="media-body name">
                        <h5 class="media-heading" th:text="${comment.user.name}"></h5>
                        <div th:text="${comment.content}"></div>
                        <div class="menu">
                            <span class="glyphicon glyphicon-thumbs-up icon"></span>
                            <div class="span-icon">
                                <span class="glyphicon glyphicon-comment" th:data-id="${comment.id}"
                                      onclick="collapseComments(this)">
                                 </span>
                                <span th:text="${comment.commentCount}"></span>
                            </div>

                            <span class="pull-right" th:text="${#dates.format(comment.gmtCreat,'yyyy-MM-dd')}"></span>

                        </div>

                        <!--二级评论-->
                        <div class="collapse col-lg-12 col-md-12 col-sm-12 col-xs-12 sub_comments"
                             th:id="${'comment-'+comment.id}">
                            <!--<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" th:each="comment:${comments}">-->
                            <!--<div class="media comments">-->
                            <!--<div class="media-left">-->
                            <!--<a href="#">-->
                            <!--<images class="media-object images-rounded" th:src="${comment.user.avatarUrl}">-->
                            <!--</a>-->
                            <!--</div>-->
                            <!--<div class="media-body name">-->
                            <!--<h5 class="media-heading" th:text="${comment.user.name}"></h5>-->
                            <!--<div th:text="${comment.content}"></div>-->
                            <!--<div class="menu">-->
                            <!--<span class="pull-right" th:text="${#dates.format(comment.gmtCreat,'yyyy-MM-dd')}"></span>-->
                            <!--</div>-->
                            <!--</div>-->
                            <!--</div>-->

                            <!--</div>-->
                            <input type="text" class="form-control col-lg-12 col-md-12 col-sm-12 col-xs-12"
                                   th:id="${'input-'+comment.id}" placeholder="评论一下...">

                            <!-- Indicates a successful or positive action -->
                            <button type="button" class="btn btn-success pull-right" onclick="comment(this)"
                                    th:data-id="${comment.id}">评论
                            </button>
                        </div>
                    </div>

                </div>

            </div>
        </div>

        <!--评论框-->
        <!--<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">-->
        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" id="comment_section">
            <h4>
                提交回复
            </h4>
            <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12 comment-sp"/>
            <div class="media col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <div class="media-left">
                    <a href="#">
                        <img class="media-object img-rounded"
                             th:src="${session.user!=null?session.user.avatarUrl:'/images/default-avatar.png'}">
                    </a>
                </div>
                <div class="media-body name">
                    <h5 class="media-heading" th:text="${session.user!=null?session.user.name:'匿名用户'}"></h5>
                </div>
            </div>
            <input type="hidden" id="question_id" th:value="${question.id}">
            <textarea class="form-control comment" id="comment" rows="3"></textarea>
            <button type="button" class="btn btn-success apply" onclick="post()">回复</button>
        </div>
    </div>
    <!--</div>-->


    <!--右侧-->
    <div class="col-lg-3 col-md-12 col-sm-12 col-xs-12 profile">

        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
            <h4>发起人</h4>
            <div class="media">
                <div class="media-left">
                    <a href="#">
                        <img class="media-object img-circle" th:src="${question.user.avatarUrl}">
                    </a>
                </div>
                <div class="media-body" style="padding-top: 10px">
                    <h5 class="media-heading" th:text="${question.user.name}"></h5>

                </div>
            </div>
        </div>
        <!--妹子-->
        <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12 question-line"/>
        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
            <h4>妹子推荐</h4>
            <img class="question-meizi img-thumbnail" src="/images/meizi.jpg">
        </div>

        <!--相关问题-->
        <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12"/>
        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
            <h4>相关问题</h4>
            <ui class="question-related">
                <li th:each="related:${relationQuestions}">
                    <a th:text="${related.title}" th:href="@{'/question/'+${related.id}}"></a></li>
            </ui>
        </div>
    </div>


</div>
</div>

<div th:insert="~{footer::foot}"></div>
</body>
</html>